package top.toptimus.dto.designStyle;

import com.alibaba.fastjson.JSON;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import top.toptimus.dto.order.orderSync.orderCommit.DTODesignPoints;

import java.util.ArrayList;
import java.util.List;

/**
 * 款式设计点更新的所需的所有数据
 *
 * @author Doge
 */
@Data
@NoArgsConstructor
public class DesignPointCompleteDTO {
    private static final Logger logger = LoggerFactory.getLogger(DesignPointCompleteDTO.class);
    private List<DesignPointDataCleanDTO> designPointDataCleanDTOS;//新的设计点数据
    private List<OldDesignPointIdDTO> oldDesignPointIdDTOS;//旧的设计点数据删除用的

    /**
     * 改orderCommit时用
     *
     * @return List<DTODesignPoints>
     */
    public List<DTODesignPoints> build() {
        List<DTODesignPoints> dtoDesignPoints =
                new ArrayList<DTODesignPoints>() {{
                    designPointDataCleanDTOS
                            .forEach(
                                    designPointDataCleanDTO ->
                                            add(
                                                    designPointDataCleanDTO.build()
                                            )
                            );
                }};
        logger.info("更新orderCommit的DTODesignPoints在这" + JSON.toJSONString(dtoDesignPoints));
        return dtoDesignPoints;
    }
}
